package logic

import (
	"ball/ballrpc/ballrpc"
	"context"

	"ball/api/internal/svc"
	"ball/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type TalkAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewTalkAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TalkAddLogic {
	return &TalkAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *TalkAddLogic) TalkAdd(req *types.TalkAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.Ballrpc.TalkAdd(l.ctx, &ballrpc.TalkAddRequest{
		UserId: req.UserId,
		Image:  req.Image,
		Name:   req.Name,
		Price:  req.Price,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "图片不能大于5mb",
		Code:    200,
		Data:    add,
	}, nil
}
